﻿<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="Synchronization.aspx.cs" Inherits="Medianamik.UI.SynchronizationManagement.Synchronization"
    MasterPageFile="../MasterPages/MedianamikModule.Master" %>

<asp:Content ID="ContextMenuContent" ContentPlaceHolderID="ContextMenu" runat="server">
    <asp:LinkButton ID="ExportTypesButton" runat="server" CssClass="Action BtSauvegarder" OnClick="ExportTypesButton_Click" Text="<%$ Resources : Medianamik_SynchronizationManagement, ExportTypes %>" />
    <asp:LinkButton ID="ImportTypesButton" runat="server" CssClass="Action BtSauvegarder" OnClick="SynchronizeTypesButton_Click" Text="<%$ Resources : Medianamik_SynchronizationManagement, SynchronizeTypes %>" />
    <asp:LinkButton ID="ExportNodesButton" runat="server" CssClass="Action BtSauvegarder" OnClick="ExportNodesButton_Click" Text="<%$ Resources : Medianamik_SynchronizationManagement, ExportNodes %>" />
    <asp:LinkButton ID="ImportNodesButton" runat="server" CssClass="Action BtSauvegarder" OnClick="SynchronizeNodesButton_Click" Text="<%$ Resources : Medianamik_SynchronizationManagement, SynchronizeNodes %>" />
</asp:Content>

<asp:Content ID="CenterContent" ContentPlaceHolderID="CenterContent" runat="server">
    <telerik:RadTabStrip id="RadTabStrip1" MultiPageID="RadMultiPage1"
        runat="server" Skin="Medianamik" EnableEmbeddedSkins="false" CausesValidation="false" ShowBaseLine="True">
        <Tabs>
           <telerik:RadTab Text="<%$ Resources : Medianamik_SynchronizationManagement, ExportTypes %>" PageViewID="ExportTypesPage" Selected="true" />
           <telerik:RadTab Text="<%$ Resources : Medianamik_SynchronizationManagement, SynchronizeTypes %>" PageViewID="SynchronizeTypesPage" Selected="true" />
           <telerik:RadTab Text="<%$ Resources : Medianamik_SynchronizationManagement, ExportNodes %>" PageViewID="ExportNodesPage" Selected="true" />
           <telerik:RadTab Text="<%$ Resources : Medianamik_SynchronizationManagement, SynchronizeNodes %>" PageViewID="SynchronizeNodesPage" Selected="true" />
        </Tabs>
    </telerik:RadTabStrip>
    
    <telerik:RadMultiPage id="RadMultiPage1" SelectedIndex="0" Runat="server" CssClass="TabPage">
       <telerik:RadPageView id="ExportTypesPage" runat="server" CssClass="ContainerEditeurPage">
            <%--TODO: Check All / Uncheck All--%>
            <%--<asp:UpdatePanel ID="TypeSelectPanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <Triggers>
                    
                </Triggers>
                <ContentTemplate>--%>
                    <h4><%=Resources("Medianamik_SynchronizationManagement", "TypesToExport") %></h4>
                    <p><a href="javascript: void(0)" class="checkAllTypes">Tout cocher</a>&nbsp;<a href="javascript: void(0)" class="uncheckAllTypes">Tout décocher</a></p>
                    <div class="BlocArbo"><telerik:RadTreeView runat="server" ID="TypesToExport" 
                        Width="100%" Height="500" EnableEmbeddedSkins="false" Skin="Medianamik" 
                        CheckBoxes="true" /></div>
                <%--</ContentTemplate>
            </asp:UpdatePanel>--%>
        </telerik:RadPageView>
        <telerik:RadPageView id="SynchronizeTypesPage" runat="server" CssClass="ContainerEditeurPage">
            <asp:CheckBox ID="SimulateSynchronizeType" runat="server" Text="<%$ Resources : Medianamik_SynchronizationManagement, SimulateSynchronizeType %>" TextAlign="Right" />
            <telerik:radupload id="TypeUploader" runat="server" initialfileinputscount="1" 
                skin="Vista" maxfileinputscount="1" InputSize="50" Width="100%"
                ControlObjectsVisibility="None" allowedfileextensions=".txt"
                OverwriteExistingFiles="true" maxfilesize="1000000" 
                TargetFolder="~/Medianamik/TemporaryFiles/" />
        </telerik:RadPageView>
        <telerik:RadPageView id="ExportNodesPage" runat="server" CssClass="ContainerEditeurPage">
                <%--TODO: Check All / Uncheck All--%>
                <%--<asp:UpdatePanel ID="TypeSelectPanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                    <Triggers>
                        
                    </Triggers>
                    <ContentTemplate>--%>
                    <table cellpadding="0" cellspacing="0" border="0" Width="100%">
                        <tr>
                            <td width="50%" valign="top">
                                <h4><%=Resources("Medianamik_SynchronizationManagement", "Types") %></h4>
                                <%--<p><a class="checkAllNodes">Tout cocher</a>&nbsp;<a class="uncheckAllNodes">Tout décocher</a></p>--%>
                                <asp:CheckBox ID="ExportAllNodes" OnCheckedChanged="ExportAllNodes_CheckedChanged" AutoPostBack="true" runat="server" Text="<%$ Resources : Medianamik_SynchronizationManagement, ExportAllNodes %>" TextAlign="Right" />
                                <div class="BlocArbo"><telerik:RadTreeView runat="server" ID="NodesToExportByType" 
                                    Width="100%" Height="500" EnableEmbeddedSkins="false" Skin="Medianamik" 
                                    CheckBoxes="true" OnNodeCheck="NodesToExportByType_NodeCheck" 
                                    OnNodeDataBound="NodesToExportByType_NodeDataBound" /></div>
                            </td>
                            <td><img src="/medianamik/images/spacer.gif" width="16" height="1" /></td>
                            <td width="50%" valign="top">
                                <h4><%=Resources("Medianamik_SynchronizationManagement", "Nodes") %></h4>
                                <p><a href="javascript: void(0)" class="checkAllNodes">Tout cocher</a>&nbsp;<a href="javascript: void(0)" class="uncheckAllNodes">Tout décocher</a></p>
                                <div class="BlocArbo"><telerik:RadTreeView runat="server" ID="NodesToExport" 
                                    Width="100%" Height="500" EnableEmbeddedSkins="false" Skin="Medianamik" 
                                    CheckBoxes="true" /></div>
                            </td>
                        </tr>
                    </table>
                        
                    <%--</ContentTemplate>
                </asp:UpdatePanel>--%>
        </telerik:RadPageView>
        <telerik:RadPageView id="SynchronizeNodesPage" runat="server" CssClass="ContainerEditeurPage">
            <asp:CheckBox ID="SimulateSynchronizeNode" runat="server" Text="<%$ Resources : Medianamik_SynchronizationManagement, SimulateSynchronizeNode %>" TextAlign="Right" />
            <telerik:radupload id="NodeUploader" runat="server" initialfileinputscount="1" 
                skin="Vista" maxfileinputscount="1" InputSize="50" Width="100%"
                ControlObjectsVisibility="None" allowedfileextensions=".txt"
                OverwriteExistingFiles="true" maxfilesize="1000000" 
                TargetFolder="~/Medianamik/TemporaryFiles/" /><br />
            <asp:CheckBox ID="PublishNodes" runat="server" Text="<%$ Resources : Medianamik_SynchronizationManagement, PublishNodes %>" />
        </telerik:RadPageView>
    </telerik:RadMultiPage><br />
        <asp:Literal ID="Log" runat="server" EnableViewState="false" Text="" />
                    <asp:Literal ID="ExceptionLog" runat="server" EnableViewState="false" Text="" />
                    <asp:Literal ID="WarningLog" runat="server" EnableViewState="false" Text="" />
</asp:Content>

<asp:Content ID="ExternalContent" ContentPlaceHolderID="ExternalContentHolder" runat="server">
    <telerik:RadScriptBlock runat="server" ID="scriptBlock">
        <script type="text/javascript">
            //<![CDATA[
            function checkAll(clientId, checked) {
                var tree = $find(clientId);
                var nodes = tree.get_allNodes();
                for (var i = 0; i < nodes.length; i++) {
                    var node = nodes[i];
                    node.set_checked(checked);
                    if(checked)
                        node.expand();
                }
            }

            $(document).ready(function() {
                $("a.checkAllTypes").click(function() { checkAll('<%= TypesToExport.ClientID %>', true) });
                $("a.uncheckAllTypes").click(function() { checkAll('<%= TypesToExport.ClientID %>', false) });
                $("a.checkAllNodes").click(function() { checkAll('<%= NodesToExport.ClientID %>', true) });
                $("a.uncheckAllNodes").click(function() { checkAll('<%= NodesToExport.ClientID %>', false) });
            });
            //]]>
        </script>
    </telerik:RadScriptBlock>
</asp:Content>